			$(document).ready(function () {
				//加载数据表格
				loadTable();
			});
			
			function  loadTable()
			{	
				var startTime=$('#startTime').val();
				var endTime=$('#endTime').val();
				var jdrids=$('#jdrids').val();
				var organIds=$('#organIds').val();
				
				
				$('#jdrStatisticInfo_datagrid').datagrid({
					cls: "theme-datagrid",
					 toolbar: '#jdrStatistic_tb',
					singleSelect: true,
 					url: cxt+"/turnoverRatioJdrStatistic/lookReasonInfo",
 					queryParams: {
 						'startTime': startTime,
 						'endTime':endTime,
 						'jdrids':jdrids,
 						'organIds':organIds
 					},
				    method: 'post',
					fitColumns:true,
					rownumbers: true, //显示序号
					columns:[[
								{field:'date',title:'日期',width:100,align:'center'},
								{field:'intonum',title:'进店人数',width:100,align:'center'},
								{field:'dealnum',title:'成交人数',width:100,align:'center',
									formatter: function(value,row,index){
										if(value==null)
										{
											return  row.dealnum='0';
										}else
										{
											return  value;
										}
									}
								},
								{field:'nodealnum',title:'未成交人数',width:100,align:'center',
									formatter: function(value,row,index){
										if(value==null)
										{
											return  row.nodealnum='0';
										}else
										{
											return  value;
										}
									}
								},
								{field:'dealratio',title:'成交率',width:80,align:'center',
									formatter: function(value,row,index){
										var dealratio=0;
										if(row.dealnum!=0 && row.intonum!=0)
										{	
											dealratio=parseFloat(row.dealnum)/parseFloat(row.intonum)*100;
										}
										return  row.dealratio=dealratio.toFixed(2)+"%";
									}
								},
								{field:'reasonratio',title:'未成交原因占比',width:80,align:'center',
									formatter: function(value,row,index){
										var date=row.date;
										return '<button href="#" style="height:25px;width:50px;background:#00A65A;color:white" onclick="lookReasonratio(\''+date+'\')">查看</button>';
									}
								}
								
						    ]]
				})
			}
			
			function  lookReasonratio(date)
			{
				$('#_reasonratio_window').window('open');
				var  startTime = $('#startTime').val();
				var  endTime = $('#endTime').val();
				var  jdrids = $('#jdrids').val();
				var  organIds = $('#organIds').val();
				var dataName=[];
				var url='/turnoverRatioJdrStatistic/getReasonRatio';
				var data={"jdrids":jdrids,"organIds":organIds,"date":date,"startTime":startTime,"endTime":endTime};
				var reData = common_ajax.ajaxFunc(url,data,"json");
				for(var i=0;i<reData.length;i++)
				{
					dataName.push(reData[i].name);
				}
				echarts(dataName,reData);
			}
			function  echarts(dataName,data)
			{
					/*疗程占比饼状图*/
					require.config({
				        paths: {
				            echarts: 'http://echarts.baidu.com/build/dist'
				        }
				    });
				     require(
				    [
				        'echarts',
				        'echarts/chart/pie',
				        'echarts/chart/bar',
				        'echarts/chart/funnel',
				        'echarts/chart/line'
				    ],
				    function (ec) {
				        var myChart = ec.init(document.getElementById('_reasonratio_echarts')); 
				        option = {
				        	    title : {
				        	        text: '疗程占比',
				        	        x:'center'
				        	    },
				        	    tooltip : {
				        	        trigger: 'item',
				        	        formatter: "{a} <br/>{b} : {c} ({d}%)"
				        	    },
				        	    legend: {
				        	        orient : 'vertical',
				        	        x : 'left',
				        	        data:dataName
				        	    },
				        	    toolbox: {
				        	        show : true,
				        	        feature : {
				        	            dataView : {show: true, readOnly: false},
				        	            magicType : {
				        	                show: true, 
				        	                type: ['pie', 'funnel'],
				        	                option: {
				        	                    funnel: {
				        	                        x: '30%',
				        	                        width: '10%',
				        	                        funnelAlign: 'left',
				        	                        max: 1548
				        	                    }
				        	                }
				        	            }
				        	        }
				        	    },
				        	    calculable : true,
				        	    series : [
				        	        {
				        	            name:'访问来源',
				        	            type:'pie',
				        	            radius : '55%',
				        	            center: ['50%', '60%'],
				        	            data:data
				        	        }	        	 
				        	    ]
				        	}
				        myChart.setOption(option); 
				        window.onresize = myChart.resize;
				    }
				);
			}
			
			